<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>异步请求工程</h1>
<div>
    <input type="button" value="异步GET请求" @click="f1()">
    <input type="button" value="异步POST请求" @click="f2()">
    <a href="/bmi.html">BMI测试</a>
    <hr>
    <a href="/reg.html">注册</a>
    <a href="/login.html">登陆</a>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{

    },
    methods:{
        f1() {
            // axios.get("/helloAxios").then(function (response) {
            //     alert(response.data);
            // })
            axios.get("/p1?name=tom&age=18").then(function (response) {
                alert(response.data);
            })
        },

        f2() {
            // axios.post("/helloAxios").then(function (response) {
            //     alert(response.data);
            // })
            let p = {title: "老冰棍儿", price: 1.0, num: 1000};
            axios.post("/p2",p).then(function (response) {
                alert(response.data);
            })
        }
    }
  })
</script>
</html>